package com.czy.mapper;

import com.czy.pojo.Clazz;
import com.czy.pojo.ClazzPage;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {

    /**
     * 条件分页查询
     */
    public List<Clazz> list(ClazzPage clazzPage);

    /**
     * 新增班级信息
     */
    @Insert("INSERT into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) " +
            "VALUES(#{name} ,#{room} ,#{beginDate},#{endDate}, #{masterId}," +
            "#{subject}, #{createTime}, #{updateTime})")
    public void insert(Clazz clazz);

    /**
     * 根据ID查询班级信息
     */
    @Select("select id, name, room, begin_date, end_date, master_id, subject, create_time, update_time from clazz " +
            "where id = #{id}")
    public Clazz getById(Integer id);

    /**
     * 修改班级信息
     */
    public void updateById(Clazz clazz);

    /**
     * 根据ID删除班级信息
     */
    @Delete("delete from clazz where id = #{id}")
    public void deleteById(Integer id);

    /**
     * 根据ID查询班级人数
     */
    @Select("select count(*) from student where clazz_id = #{id}")
    public Integer getNum(Integer id);

    /**
     * 查询全部班级信息
     */
    @Select("select id, name, room, begin_date, end_date, master_id, subject, create_time, update_time from clazz")
    public List<Clazz> findAll();


    /**
     * 根据ID查询班级名字
     */
    List<Object> getClazzName(List<Object> clazzList);
}
